package com.xmkj.carwash.mine.activity;

import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.common.mvp.BaseMvpActivity;
import com.common.mvp.BasePresenter;
import com.common.retrofit.methods.FanKuiMethods;
import com.common.retrofit.subscriber.CommonSubscriber;
import com.common.retrofit.subscriber.SubscriberListener;
import com.common.utils.EmptyUtils;
import com.xmkj.carwash.R;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by chen on 2018/4/2.
 */

public class DeviceActivity extends BaseMvpActivity {
    @BindView(R.id.et_content)
    EditText etContent;
    @BindView(R.id.tv_submit)
    TextView tvSubmit;

    @Override
    protected BasePresenter createPresenterInstance() {
        return null;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_device;
    }

    @Override
    protected void onViewCreated() {

    }

    @Override
    protected void doLogicFunc() {
    attachClickListener(tvSubmit);
    }

    @Override
    protected void onViewClicked(View view) {
        if(view.getId()==tvSubmit.getId()){
            if(EmptyUtils.isEmpty(getEditTextStr(etContent))){
                showToastMsg("请输入您的意见");
                return;
            }
            gotoFeadBack();
        }
    }

    private void gotoFeadBack() {
        showProgressingDialog();
        CommonSubscriber<Object> subscriber = new CommonSubscriber<>(new SubscriberListener() {
            @Override
            public void onNext(Object o) {
                showToastMsg("反馈成功");
                showProgressingDialog();
                onBackPressed();
            }

            @Override
            public void onError(String e, int code) {
                dismissProgressDialog();
                showToastMsg(e);
            }
        });

        FanKuiMethods.getInstance().saveData(subscriber, uid, hashid, getEditTextStr(etContent));
        rxManager.add(subscriber);
    }

    @Override
    protected void setNavigation() {
        setNavigationBack("意见反馈");
    }



    @Override
    public void bindKnife() {
        ButterKnife.bind(this);

    }
}
